"""
双端队列: 队列两端都可以插入和删除
头插,尾插
头出,尾出
"""


class DoubleEndedQueue(object):
    """双端队列"""
    def __init__(self):
        self.items = []

    def is_empty(self):
        """判空"""
        return self.items == []

    def add_head(self, item):
        """头插"""
        self.items.insert(0, item)

    def add_rear(self, item):
        """尾插"""
        self.items.append(item)

    def remove_head(self):
        """头出"""
        return self.items.pop(0)

    def remove_rear(self):
        """尾出"""
        return self.items.pop()

    def size(self):
        """队列大小"""
        return len(self.items)

